<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="support.*, java.util.*, java.sql.*" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Provide More Degrees</title>
</head>
<body>

  <% 
	Student student = (Student)session.getAttribute("student");
	Degree degree = (Degree)session.getAttribute("degree");
	ArrayList <Degree> degreeList;
	//Add degree to array of degrees in student
	if (session.getAttribute("degreelist") == null)
	{
	   degreeList = new ArrayList<Degree>();
	   session.setAttribute("degreelist", degreeList);
	}
	else
	{
	   degreeList = (ArrayList<Degree>)session.getAttribute("degreelist");
	}
	
  
	if (request.getParameter("deleteDegree") != null)
	{
		int index = Integer.parseInt(request.getParameter("deleteDegree"));
		degreeList.remove(index);
	}
	else
	{	
		degree.title(request.getParameter("title"));
		degree.date(request.getParameter("date"));
		degree.gpa(Double.parseDouble(request.getParameter("gpa")));
		String newDiscipline = request.getParameter("otherdegree");
		if(newDiscipline != "")
		{
			degree.newDiscipline(newDiscipline);
			degree.discipline(-1);
		}
		else
		{
			degree.discipline(Integer.parseInt(request.getParameter("discipline")));
			degree.newDiscipline("");
		}
		
		degreeList.add(degree);
	}
  %>

	<h3>Previously entered in information:</h3>

	<p><%= "Full name: " + student.getFirstName() + " " + student.getMiddleName() + " " + student.getLastName() %></br>
	<%= "Country of Citizenship: " + student.getCitizenshipName() %></br>
	<% if (student.getState() != "") { %>
		<%= "Address: " + student.getAddress() + ", " + student.getCity() + " " + student.getState() + ", " + student.getZipcode() %>
	<% } else {%>
		<%= "Address: " + student.getAddress() + ", " + student.getCity() + ", " + student.getZipcode() %></p>
	<% } %>
	

	
	<%
   //Print out degree information if coming from more degrees
   if (degreeList != null) {
      for (int i = 0; i < degreeList.size(); i++) {
%>
	<form method="POST" action="degreeList.jsp">
         <p><b><%= "Degree #" + (i+1) + ": " %></b><br>
         <%= degreeList.get(i).getDisciplineName() + ", " + degreeList.get(i).getTitle() %><br> 
         <%= degreeList.get(i).getUniversityName() %><br>
         <%= degreeList.get(i).getLocationName() %><br>
         <%= "Year of Graduation: " + degreeList.get(i).getDate() %><br>
         <%= "GPA: " + degreeList.get(i).getGpa() %><br>
         <input type="hidden" name="deleteDegree" value=<%=i %>>
         <input type="submit" value="Delete Degree">
    </form>
<%
      }
   }
%>

<h3>What would you like to do?</h3>

<form method="GET" action="location.jsp">
<input type="hidden" name="action" value="moredegrees"/>
<input type="submit" value="Submit Next Degree"/>         
</form>

<form method="GET" action="specialization.jsp">
<input type="submit" value="Done"/>         
</form>

</body>
</html>